package dbkey

import (
	"fmt"
	"strconv"
	"testing"
	"time"
)

func TestParseTimeString(t *testing.T) {
	fmt.Println(time.Now().Format(DateTimeCNFormat))
	loc, _ := time.LoadLocation(DateTimeZone)
	//fmt.Println(time.Now().In(loc).Format(DateTimeIndiaFormat))
	ts := "2023-07-05 15:32:05 +0800"
	tm, err := time.Parse(DateTimeCNFormat2, ts)
	if err != nil {
		t.Error(err)
	}
	fmt.Println(tm)

	tm, err = time.ParseInLocation(DateTimeCNFormat2, ts, loc)
	fmt.Println(tm)
}

func TestLtv(t *testing.T) {
	now := time.Now()
	loc, _ := time.LoadLocation(DateTimeZone)
	start := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, loc).AddDate(0, 0, -1)
	end := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 0, loc).AddDate(0, 0, -1)
	var idx int
	var st, et time.Time
	var statDay int64
	for idx = 30; idx > 1; idx-- {
		statDay, _ = strconv.ParseInt(start.AddDate(0, 0, -(idx-1)).Format(DateFormat2), 10, 64)
		st = start.AddDate(0, 0, -(idx - 1))
		et = end.AddDate(0, 0, -(idx - 1))
		t.Log(idx, statDay, st, et)
	}
}
